package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.TowerGoods;
import com.ruoyi.system.domain.TowerLevel;
import com.ruoyi.system.mapper.TowerGoodsMapper;
import com.ruoyi.system.mapper.TowerLevelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TowerMapper;
import com.ruoyi.system.domain.Tower;
import com.ruoyi.system.service.ITowerService;

/**
 * 爬塔实体Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-08-31
 */
@Service
public class TowerServiceImpl implements ITowerService 
{
    @Autowired
    private TowerMapper towerMapper;

    /**
     * 查询爬塔实体
     * 
     * @param id 爬塔实体主键
     * @return 爬塔实体
     */
    @Override
    public Tower selectTowerById(Integer id)
    {
        return towerMapper.selectTowerById(id);
    }

    /**
     * 查询爬塔实体列表
     * 
     * @param tower 爬塔实体
     * @return 爬塔实体
     */
    @Override
    public List<Tower> selectTowerList(Tower tower)
    {
        return towerMapper.selectTowerList(tower);
    }

    /**
     * 新增爬塔实体
     * 
     * @param tower 爬塔实体
     * @return 结果
     */
    @Override
    public int insertTower(Tower tower)
    {
        tower.setCreateTime(DateUtils.getNowDate());
        return towerMapper.insertTower(tower);
    }

    /**
     * 修改爬塔实体
     * 
     * @param tower 爬塔实体
     * @return 结果
     */
    @Override
    public int updateTower(Tower tower)
    {
        tower.setUpdateTime(DateUtils.getNowDate());
        return towerMapper.updateTower(tower);
    }

    /**
     * 批量删除爬塔实体
     * 
     * @param ids 需要删除的爬塔实体主键
     * @return 结果
     */

    @Override
    public int deleteTowerByIds(Integer[] ids)
    {

        return towerMapper.deleteTowerByIds(ids);
    }

    /**
     * 删除爬塔实体信息
     * 
     * @param id 爬塔实体主键
     * @return 结果
     */
    @Autowired
    private TowerLevelMapper towerLevelMapper;

    @Autowired
    private TowerGoodsMapper towerGoodsMapper;

    @Override
    public int deleteTowerById(Integer id)
    {

        //删除
        towerLevelMapper.deleteTowerLevelByTowerId(id);


        //删除
        towerGoodsMapper.deleteTowerGoodsByTowerId(id);

        return towerMapper.deleteTowerById(id);
    }
}
